home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / UTILITIE / CONVERSI / 1396.ZIP / ALTERN22.DOC < prev    next >
Text File  |  1988-12-02  |  16KB  |  346 lines

  1.  
  2.  
  3.  
  4.                              ALTERN VERSION 2.2
  5.  
  6.                   ALTERNATE AND GLOBAL REPLACEMENT PROGRAM
  7.  
  8.                               By C.R.J. Currie
  9.         PURPOSE .............................................1
  10.  
  11.         PREPARATION..........................................2
  12.  
  13.         FORMAT OF STRING-LIST FILES..........................3
  14.  
  15.             a) Lists for Alternate Replacement...............3
  16.  
  17.             b) Lists for Global Replacement..................3
  18.  
  19.         FORMAT OF FILE-LIST FILE.............................4
  20.  
  21.         PARAGRAPH MARKER FILES...............................4
  22.  
  23.         RUNNING ALTERN.......................................4
  24.  
  25.         RUNNING THE FILEMAKE PROGRAM.........................5
  26.  
  27.         LIMITATIONS..........................................6
  28.  
  29.         HISTORY..............................................7
  30.  
  31.         SOFTWARE LICENCE.....................................8
  32.  
  33.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 1
  34.  
  35.  
  36.  
  37.                              ALTERN VERSION 2.2
  38.  
  39.                   ALTERNATE AND GLOBAL REPLACEMENT PROGRAM
  40.  
  41.                               By C.R.J. Currie
  42.  
  43.             1. PURPOSE
  44.  
  45.                ALTERN is a utility which helps to convert text files to
  46.                different formats or to prepare them for input to a
  47.                typesetter or output to a printer which your text editor
  48.                cannot drive.  It allows the global replacement of every
  49.                string in a prepared list, or the alternate replacement of
  50.                paired strings.  The last function is essential to convert
  51.                files prepared with a text editor such as Wordstar, which
  52.                uses 'toggles' to change text emphasis or type size, to a
  53.                format which requires that each style or size be overtly
  54.                specified.
  55.  
  56.                     Most text editors cannot cope with alternate
  57.                replacement, with bulk replacement of a series of strings at
  58.                once, or with automatic replacement throughout a set of
  59.                files.  Some cannot even replace their own control codes.
  60.                ALTERN can do all that.  It doesn't change your original
  61.                file, but makes a modified copy with the extension .COD.
  62.  
  63.                     For example a single run could replace every occurrence
  64.                of GOAT by ELEPHANT, every carriage return by a linefeed
  65.                with the 8th bit set, every odd-numbered occurrence of CAT
  66.                by DOG, and every even-numbered occurrence of CAT by SHEEP,
  67.                in each one of 100 files.
  68.  
  69.                     ALTERN uses single-character input and processes text a
  70.                paragraph at at time. The default paragraph marker is the
  71.                carriage return -- linefeed sequence (0D0A hex), but files
  72.                in formats which use other markers can be read and written.
  73.  
  74.                     ALTERN can also search e.g. Wordstar files for strings
  75.                in which some bytes may or may not have the eighth bit set,
  76.                and replace them.  Version 2.2 cannot search independently
  77.                of case: REAGAN and Reagan are treated as different strings.
  78.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 2
  79.  
  80.  
  81.             2. PREPARATION
  82.  
  83.                ALTERN requires two prepared files, held in the current
  84.                directory, listing codes for replacement: one for those to
  85.                be replaced alternately, another for those to be replaced
  86.                globally. Even if you only want to do global replacements,
  87.                you must prepare a dummy list of alternate replacements (see
  88.                3 a) below).  If you want to convert more than one file at a
  89.                time, you will also need a file listing the files to be
  90.                converted.  If your input or output files are to have
  91.                non-standard paragraph markers you will need a further file
  92.                for each of the two possible markers.
  93.  
  94.                     These files must be ASCII text files and can be
  95.                prepared with a text editor, such as Wordstar in
  96.                Non-Document mode, which can write ASCII files, or by
  97.                copying the console output to a file.  If you need to handle
  98.                strings which include characters that cannot be typed from
  99.                the keyboard, use the FILEMAKE utility to create the file or
  100.                files which list those strings.  Your text editor should be
  101.                able to load the resulting files so that you can add further
  102.                strings to the lists.
  103.  
  104.                     Strings which include double quotation marks (") MUST
  105.                NOT be included in the lists, but you can type them in while
  106.                running ALTERN.
  107.  
  108.                     The prepared lists, and the files to be converted, must
  109.                be in the current directory unless you have set a data path
  110.                with DPATH or some equivalent utility.
  111.  
  112.                     The order of sets of strings in the string-list files
  113.                is significant. That feature can be used to achieve complex
  114.                or tricky replacements: e.g. you can replace 11/21 by some
  115.                special code to print it as a fraction, and then replace 1/2
  116.                by another special code, in a single run. Doing it the other
  117.                way round will give erroneous output.
  118.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 3
  119.  
  120.  
  121.             3. FORMAT OF STRING-LIST FILES
  122.                a) LISTS FOR ALTERNATE REPLACEMENT
  123.  
  124.                   Each line should include a string to be replaced and the
  125.                   first and second replacements. Each string should be
  126.                   inclosed in double quotation marks and separated by a comma
  127.                   from the next. The last line of the file should consist of
  128.                   the word END in upper case. Example:
  129.  
  130.                   "CAT","DOG","SHEEP"
  131.                   ",",";","."
  132.                   END
  133.  
  134.                   In this example, all occurrences of CAT in the input file or
  135.                   files will be replaced alternately by DOG and SHEEP in the
  136.                   output file or files, and all commas will be replaced
  137.                   alternately by semicolons and full stops.
  138.  
  139.                   If you only want a dummy alternate-replacement file, type
  140.                   only one line of strings, all of which should be the same.
  141.  
  142.                   Example:
  143.  
  144.                   "A","A","A"
  145.                   END
  146.  
  147.                b) LISTS FOR GLOBAL REPLACEMENT
  148.  
  149.                   Each line should include a string to be replaced and the
  150.                   string to replace it. Each string should be inclosed in
  151.                   double quotation marks and the first should be separated by
  152.                   a comma from the next. The last line of the file should
  153.                   consist of the word END in upper case. Example:
  154.  
  155.                   "GOAT","ELEPHANT"
  156.                   "*",","
  157.                   END
  158.  
  159.                   In this example, all occurrences of GOAT in the input file
  160.                   or files will be replaced by ELEPHANT in the output file or
  161.                   files, and all asterisks will be replaced by commas.
  162.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 4
  163.  
  164.  
  165.             4. FORMAT OF FILE-LIST FILE
  166.  
  167.                  The list of files to be converted should consist simply of
  168.                  one filespec on each line. Example:
  169.  
  170.                  CHUMLEY.TXT
  171.                  DINGBAT
  172.                  FILE3.DAT
  173.  
  174.             5.  PARAGRAPH MARKER FILES
  175.  
  176.                If your input or output files need a paragraph marker other
  177.                than the default, you can put them in two files in the
  178.                current directory which MUST be called PARIN and PAROUT
  179.                respectively. ALTERN always searches the directory for those
  180.                files and only uses the default marker if the relevant file
  181.                is missing. The files should consist of the marker code as a
  182.                single string inclosed in double quotation marks.
  183.  
  184.  
  185.             6. RUNNING ALTERN
  186.  
  187.                Simply type ALTERN22 at the DOS command-line prompt and
  188.                press the Return key. All answers to prompts within the
  189.                program should be terminated by pressing Return. ALTERN will
  190.                request the name of the list of input files (if any). If you
  191.                only want to process one file, just press Return at that
  192.                prompt. ALTERN will then ask you for the filespec of the
  193.                single file you wish to process. It will then request
  194.                filespecs for the string-list file containing alternate
  195.                replacements, and the file containing global replacements.
  196.                Press Return after answering each prompt. ALTERN will also
  197.                ask you if you wish to check for 8th-bit flags (you should
  198.                normally answer Y if the input file is a Wordstar file), and
  199.                if you want to type in additional sets of strings for
  200.                alternate or global replacement from the keyboard. Answer N
  201.                unless you need to replace or insert strings containing
  202.                double quotation marks.
  203.  
  204.                ALTERN is not particularly error-friendly, so you should
  205.                check your answers to each prompt before pressing Return.
  206.  
  207.                You should be able to reroute console input for the ALTERN
  208.                prompts from a DOS text file by typing
  209.  
  210.                   ALTERN22 <filename.ext
  211.  
  212.                 at the DOS prompt.
  213.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 5
  214.  
  215.  
  216.             7. RUNNING THE FILEMAKE PROGRAM
  217.  
  218.                You only need to use this program if the strings to be
  219.                replaced or inserted include characters you can't type into
  220.                a text file from the keyboard, e.g. control bytes. You could
  221.                use DEBUG instead.
  222.  
  223.                To run the program simply type FILEMAKE at the DOS prompt
  224.                and press the return key. The program will ask you for the
  225.                name of the string-list file you are creating and whether
  226.                you want two strings per line (for GLOBAL replacement) or
  227.                three (for ALTERNATE replacment). It will go on prompting
  228.                for extra lines until you type 999 as the ASCII code for the
  229.                FIRST string in a line. DON'T type 999 in the middle of a
  230.                line.
  231.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 6
  232.  
  233.  
  234.             8. LIMITATIONS
  235.  
  236.                Replacement in BINARY files is NOT reliable:  ALTERN will
  237.                stop processing when 1A hex (^Z) is reached in the input
  238.                file.
  239.  
  240.                Maximum size of file which can be processed: half drive
  241.                space
  242.  
  243.                Maximum number of files per batch searched: 100
  244.  
  245.                Maximum number of string-sets for alternate replacement: 64
  246.  
  247.                Maximum number of string-sets for global replacement: 64
  248.                (You can replace more strings globally if you include them
  249.                in the list of alternate replacements with the desired
  250.                replacement in both the second and third positions on the
  251.                line. That, however, will reduce the number of genuine
  252.                alternate replacements you can make.)
  253.  
  254.                Maximum length of individual strings to be replaced or
  255.                inserted: 254 bytes
  256.  
  257.                Maximum theoretical length of paragraph in input file: 32767
  258.                bytes. In practice it will be considerably less, but
  259.                paragraphs of 2k and above have been successfully processed.
  260.  
  261.                The total length of all strings (including lists and input
  262.                and output paragraphs) which can be held in memory at once
  263.                is probably not more than a 64k block of address space.
  264.  
  265.                No case-independent search.
  266.  
  267.                {continued...}
  268.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 7
  269.  
  270.  
  271.                Nested pairs for alternate replacement:  ALTERN treats each
  272.                pair separately.  That can be significant for typesetting
  273.                purposes.  Consider the following example, in which the
  274.                Wordstar toggles for underline (^S) and bold (^B) are to be
  275.                replaced by typesetting codes for italic/non-italic and
  276.                bold/normal text.
  277.  
  278.                ^SItalic on ^BNow Bold italic ^BNormal italic ^SNormal Roman
  279.  
  280.                The typesetter has no code for 'turn bolding off'; one must
  281.                specify normal weight either in Roman or italic, usually the
  282.                former.  Thus alternate replacement produces
  283.  
  284.                [code for italic]Italic on [code for bold]Now Bold italic
  285.                [code for normal Roman]Normal Italic [code for normal Roman]
  286.                Normal Roman
  287.  
  288.                so that the phrase 'Normal Italic' is wrongly set in Roman.
  289.                There is no way round this problem except to avoid nested
  290.                pairs when the file is originally typed, e.g.
  291.  
  292.                ^SItalic on^S ^B^SNow bold italic^S^B ^SNormal italic
  293.                ^SNormal Roman
  294.  
  295.                which will produce the desired result when ALTERN is run
  296.                correctly on it.
  297.  
  298.             9. HISTORY
  299.  
  300.                     The original version of ALTERN was written in 1986.  It
  301.                was limited to the alternate replacement of single bytes by
  302.                strings and had no provision for global replacement, for
  303.                handling codes which could not be typed from the keyboard,
  304.                or for altering input and output paragraph markers.
  305.  
  306.                     Compiled versions were produced for CP/M, generic
  307.                MS-DOS, and the TRS-80 Model III.  The source code was
  308.                published in NATGUG News.
  309.  
  310.                      The program was completely redesigned and rewritten as
  311.                version 2.0 in June 1988 and has undergone two major
  312.                revisions since.
  313.         Altern v.2.2 documentation (c) C.R.J. Currie 1988 p. 8
  314.  
  315.  
  316.            10. SOFTWARE LICENCE
  317.  
  318.                Copyright (c) 1988 C.R.J. Currie. All Rights Reserved.
  319.  
  320.                You are free to use, copy and distribute ALTERN22 and
  321.                FILEMAKE for noncommercial use IF:
  322.  
  323.                        NO FEE IS CHARGED FOR USE, COPYING OR DISTRIBUTION.
  324.  
  325.                        THE PROGRAMS ARE NOT MODIFIED IN ANY WAY.
  326.  
  327.                Clubs and user groups may charge a nominal fee (less than
  328.                $10)  for expenses and handling while distributing ALTERN.
  329.  
  330.                This program is provided AS IT IS without any warranty,
  331.                expressed or implied, including but not limited to fitness
  332.                for a particular purpose.
  333.  
  334.                If you find ALTERN22 useful, a contribution of $10 would be
  335.                appreciated.
  336.  
  337.                 Send contributions to:
  338.  
  339.                C.R.J. Currie
  340.                c.o. Institute of Historical Research
  341.                Senate House
  342.                Malet Street
  343.                London WC1E 7HU
  344.                U.K.
  345.  
  346.